<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
   
   <meta name="description" content="string operations">
    
    <meta name="author" content="John S. Urban" >
    <link rel="icon" href="../favicon.png">

    <title>split &ndash; M_strings</title>

    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../css/pygments.css" rel="stylesheet">
    <link href="../css/font-awesome.min.css" rel="stylesheet">
    <link href="../css/local.css" rel="stylesheet">
    
    <link  href="../tipuesearch/tipuesearch.css" rel="stylesheet">
    
    

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <script src="../js/jquery-2.1.3.min.js"></script>
    <script src="../js/svg-pan-zoom.min.js"></script>

  </head>

  <body>

    <!-- Fixed navbar -->
    <nav class="navbar navbar-inverse navbar-fixed-top">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="../index.html">M_strings </a>
        </div>
        <div id="navbar" class="navbar-collapse collapse">
          <ul class="nav navbar-nav">
        
            <li class="dropdown hidden-xs visible-sm visible-md hidden-lg">
              <a href="#" class="dropdown-toggle"
              data-toggle="dropdown" role="button"
              aria-haspopup="true"
     aria-expanded="false">Contents <span class="caret"></span></a>
        <ul class="dropdown-menu">
          
              
            <li><a href="../lists/files.html">Source Files</a></li>
        
        
        
            <li><a href="../lists/modules.html">Modules</a></li>
        
            
                                
            <li><a href="../lists/procedures.html">Procedures</a></li>
        
               
            <li><a href="../lists/types.html">Derived Types</a></li>
        
        
            </ul>
            </li>


<li class="visible-xs hidden-sm visible-lg"><a href="../lists/files.html">Source Files</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/modules.html">Modules</a></li>



<li class="visible-xs hidden-sm visible-lg"><a href="../lists/procedures.html">Procedures</a></li>

                             
<li class="visible-xs hidden-sm visible-lg"><a href="../lists/types.html">Derived Types</a></li>


          </ul>
        
        <form action="../search.html" class="navbar-form navbar-right" role="search">
        <div class="form-group">
          <input type="text" class="form-control" placeholder="Search" name="q" id="tipue_search_input" autocomplete="off" required>
        </div>
<!--
        <button type="submit" class="btn btn-default">Submit</button>
-->
        </form>
        
        </div><!--/.nav-collapse -->
      </div>
    </nav>

    <div class="container">
    
  
  <div class="row">
    <h1>split
      <small>Subroutine</small>
    
    </h1>
    
<div class="row">
  <div class="col-lg-12">
<div class="well well-sm">
  <ul class="list-inline" style="margin-bottom:0px;display:inline">
     
     
     
     
    
    
     <li><i class="fa fa-list-ol"></i>
       <a data-toggle="tooltip"
    data-placement="bottom" data-html="true"
    title=" 4.4% of total for procedures.">108 statements</a>
     </li> 
     
     
     
    <li><i class="fa fa-code"></i><a href="../src/M_strings.f90"> Source File</a></li>
     
     
  </ul>
  <ol class="breadcrumb in-well text-right">
  
    
     <li><a href='../sourcefile/m_strings.f90.html'>M_strings.f90</a></li>
    
     <li><a href='../module/m_strings.html'>M_strings</a></li>
    
  
     <li class="active">split</li>
  </ol>
</div>
</div>
</div>
<script>
  $(function () {
  $('[data-toggle="tooltip"]').tooltip()
  })
</script>

  </div>
  
  <div class="row">
    <div class="col-md-3 hidden-xs hidden-sm visible-md visible-lg">
    
<div id="sidebar">
  
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-0">Variables</a></h3></div>
  <div id="vars-0" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/split.html#variable-dlim~2">dlim</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-i10~5">i10</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-i20">i20</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-i30">i30</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-ibegin~4">ibegin</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-icol~2">icol</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-icount~6">icount</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-idlim~2">idlim</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-ifound~2">ifound</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-ii~2">ii</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-iiii">iiii</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-imax~2">imax</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-inotnull">inotnull</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-ireturn">ireturn</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-iterm~2">iterm</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-lgth~9">lgth</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-n~3">n</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-nlls">nlls</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-ordr">ordr</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/split.html#src">split</a>
  </div>
</div>



</div>

    </div>
    
    <div class="col-md-9" id='text'>
    <h2>
public subroutine split(input_line, array, delimiters, order, nulls)
    
    
   
</h2>
    
  


    
    <h2 id="name">NAME</h2>
<div class="codehilite"><pre><span></span><code>split(3f) - [M_strings:TOKENS] parse string into an array using
specified delimiters
(LICENSE:PD)
</code></pre></div>

<h2 id="synopsis">SYNOPSIS</h2>
<div class="codehilite"><pre><span></span><code>subroutine split(input_line,array,delimiters,order,nulls)

 character(len=*),intent(in)              :: input_line
 character(len=:),allocatable,intent(out) :: array(:)
 character(len=*),optional,intent(in)     :: delimiters
 character(len=*),optional,intent(in)     :: order
 character(len=*),optional,intent(in)     :: nulls
</code></pre></div>

<h2 id="description">DESCRIPTION</h2>
<div class="codehilite"><pre><span></span><code> SPLIT(3f) parses a string using specified delimiter characters and
 store tokens into an allocatable array
</code></pre></div>

<h2 id="options">OPTIONS</h2>
<div class="codehilite"><pre><span></span><code><span class="n">INPUT_LINE</span>  <span class="n">Input</span> <span class="n">string</span> <span class="n">to</span> <span class="n">tokenize</span>

<span class="kr">ARRAY</span>       <span class="n">Output</span> <span class="n">array</span> <span class="n">of</span> <span class="n">tokens</span>

<span class="n">DELIMITERS</span>  <span class="n">List</span> <span class="n">of</span> <span class="n">delimiter</span> <span class="n">characters</span><span class="p">.</span>
            <span class="n">The</span> <span class="n">default</span> <span class="n">delimiters</span> <span class="n">are</span> <span class="n">the</span> <span class="s">&quot;whitespace&quot;</span> <span class="n">characters</span>
            <span class="p">(</span><span class="n">space</span><span class="p">,</span> <span class="n">tab</span><span class="p">,</span><span class="n">new</span> <span class="n">line</span><span class="p">,</span> <span class="n">vertical</span> <span class="n">tab</span><span class="p">,</span> <span class="n">formfeed</span><span class="p">,</span> <span class="n">carriage</span>
            <span class="n">return</span><span class="p">,</span> <span class="n">and</span> <span class="n">null</span><span class="p">).</span> <span class="n">You</span> <span class="n">may</span> <span class="n">specify</span> <span class="n">an</span> <span class="n">alternate</span> <span class="n">set</span> <span class="n">of</span>
            <span class="n">delimiter</span> <span class="n">characters</span><span class="p">.</span>

            <span class="n">Multi</span><span class="o">-</span><span class="n">character</span> <span class="n">delimiters</span> <span class="n">are</span> <span class="n">not</span> <span class="n">supported</span> <span class="p">(</span><span class="n">Each</span>
            <span class="n">character</span> <span class="n">in</span> <span class="n">the</span> <span class="n">DELIMITERS</span> <span class="n">list</span> <span class="n">is</span> <span class="n">considered</span> <span class="n">to</span> <span class="n">be</span>
            <span class="n">a</span> <span class="n">delimiter</span><span class="p">).</span>

            <span class="n">Quoting</span> <span class="n">of</span> <span class="n">delimiter</span> <span class="n">characters</span> <span class="n">is</span> <span class="n">not</span> <span class="n">supported</span><span class="p">.</span>

<span class="n">ORDER</span> <span class="n">SEQUENTIAL</span><span class="p">|</span><span class="n">REVERSE</span><span class="p">|</span><span class="n">RIGHT</span>  <span class="n">Order</span> <span class="n">of</span> <span class="n">output</span> <span class="n">array</span><span class="p">.</span>
            <span class="n">By</span> <span class="n">default</span> <span class="kr">ARRAY</span> <span class="n">contains</span> <span class="n">the</span> <span class="n">tokens</span> <span class="n">having</span> <span class="n">parsed</span>
            <span class="n">the</span> <span class="n">INPUT_LINE</span> <span class="n">from</span> <span class="n">left</span> <span class="n">to</span> <span class="n">right</span><span class="p">.</span> <span class="n">If</span> <span class="n">ORDER</span><span class="o">=</span><span class="s">&#39;RIGHT&#39;</span>
            <span class="n">or</span> <span class="n">ORDER</span><span class="o">=</span><span class="s">&#39;REVERSE&#39;</span> <span class="n">the</span> <span class="n">parsing</span> <span class="n">goes</span> <span class="n">from</span> <span class="n">right</span> <span class="n">to</span> <span class="n">left</span><span class="p">.</span>
            <span class="p">(</span><span class="n">This</span> <span class="n">can</span> <span class="n">be</span> <span class="n">accomplished</span> <span class="n">with</span> <span class="n">array</span> <span class="n">syntax</span> <span class="n">in</span> <span class="n">modern</span>
            <span class="n">Fortran</span><span class="p">,</span> <span class="n">but</span> <span class="n">was</span> <span class="n">more</span> <span class="n">useful</span> <span class="n">pre</span><span class="o">-</span><span class="n">fortran90</span><span class="p">).</span>

<span class="n">NULLS</span><span class="o">=</span><span class="n">IGNORE</span><span class="p">|</span><span class="kr">RETURN</span><span class="p">|</span><span class="n">IGNOREEND</span>  <span class="n">Treatment</span> <span class="n">of</span> <span class="n">null</span> <span class="n">fields</span><span class="p">.</span>
            <span class="n">By</span> <span class="n">default</span> <span class="n">adjacent</span> <span class="n">delimiters</span> <span class="n">in</span> <span class="n">the</span> <span class="n">input</span> <span class="n">string</span>
            <span class="n">do</span> <span class="n">not</span> <span class="n">create</span> <span class="n">an</span> <span class="n">empty</span> <span class="n">string</span> <span class="n">in</span> <span class="n">the</span> <span class="n">output</span> <span class="n">array</span><span class="p">.</span> <span class="n">if</span>
            <span class="n">NULLS</span><span class="o">=</span><span class="s">&#39;return&#39;</span> <span class="n">adjacent</span> <span class="n">delimiters</span> <span class="n">create</span> <span class="n">an</span> <span class="n">empty</span> <span class="n">element</span>
            <span class="n">in</span> <span class="n">the</span> <span class="n">output</span> <span class="kr">ARRAY</span><span class="p">.</span> <span class="n">If</span> <span class="n">NULLS</span><span class="o">=</span><span class="s">&#39;ignoreend&#39;</span> <span class="n">then</span> <span class="n">only</span>
            <span class="n">trailing</span> <span class="n">delimiters</span> <span class="n">at</span> <span class="n">the</span> <span class="n">right</span> <span class="n">of</span> <span class="n">the</span> <span class="n">string</span> <span class="n">are</span> <span class="n">ignored</span><span class="p">.</span>
</code></pre></div>

<h2 id="examples">EXAMPLES</h2>
<p>Sample program:</p>
<div class="codehilite"><pre><span></span><code><span class="nv">program</span> <span class="nv">demo_split</span>
<span class="nv">use</span> <span class="nv">M_strings</span>, <span class="nv">only</span>: <span class="nv">split</span>
<span class="nv">implicit</span> <span class="nv">none</span>
<span class="nv">integer</span> :: <span class="nv">i</span>
<span class="nv">character</span><span class="ss">(</span><span class="nv">len</span><span class="o">=*</span><span class="ss">)</span>,<span class="nv">parameter</span>     :: <span class="nv">line</span><span class="o">=&amp;</span>
<span class="s1">&#39;</span><span class="s">  aBcdef   ghijklmnop qrstuvwxyz  1:|:2     333|333 a B cc    </span><span class="s1">&#39;</span>
<span class="nv">character</span><span class="ss">(</span><span class="nv">len</span><span class="o">=</span>:<span class="ss">)</span>,<span class="nv">allocatable</span> :: <span class="nv">array</span><span class="ss">(</span>:<span class="ss">)</span> <span class="o">!</span> <span class="nv">output</span> <span class="nv">array</span> <span class="nv">of</span> <span class="nv">tokens</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">INPUT LINE:[</span><span class="s1">&#39;</span><span class="o">//</span><span class="nv">line</span><span class="o">//</span><span class="s1">&#39;</span><span class="s">]</span><span class="s1">&#39;</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(70(&quot;=&quot;))</span><span class="s1">&#39;</span><span class="ss">)</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">typical call:</span><span class="s1">&#39;</span>
   <span class="k">call</span> <span class="nl">split</span><span class="ss">(</span><span class="nv">line</span>,<span class="nv">array</span><span class="ss">)</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(i0,&quot; ==&gt; &quot;,a)</span><span class="s1">&#39;</span><span class="ss">)(</span><span class="nv">i</span>,<span class="nv">trim</span><span class="ss">(</span><span class="nv">array</span><span class="ss">(</span><span class="nv">i</span><span class="ss">))</span>,<span class="nv">i</span><span class="o">=</span><span class="mi">1</span>,<span class="nv">size</span><span class="ss">(</span><span class="nv">array</span><span class="ss">))</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">SIZE:</span><span class="s1">&#39;</span>,<span class="nv">size</span><span class="ss">(</span><span class="nv">array</span><span class="ss">)</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(70(&quot;-&quot;))</span><span class="s1">&#39;</span><span class="ss">)</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">custom list of delimiters (colon and vertical line):</span><span class="s1">&#39;</span>
   <span class="k">call</span> <span class="nl">split</span><span class="ss">(</span><span class="nv">line</span>,<span class="nv">array</span>,<span class="nv">delimiters</span><span class="o">=</span><span class="s1">&#39;</span><span class="s">:|</span><span class="s1">&#39;</span>,<span class="o">&amp;</span>
   <span class="o">&amp;</span> <span class="nv">order</span><span class="o">=</span><span class="s1">&#39;</span><span class="s">sequential</span><span class="s1">&#39;</span>,<span class="nv">nulls</span><span class="o">=</span><span class="s1">&#39;</span><span class="s">ignore</span><span class="s1">&#39;</span><span class="ss">)</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(i0,&quot; ==&gt; &quot;,a)</span><span class="s1">&#39;</span><span class="ss">)(</span><span class="nv">i</span>,<span class="nv">trim</span><span class="ss">(</span><span class="nv">array</span><span class="ss">(</span><span class="nv">i</span><span class="ss">))</span>,<span class="nv">i</span><span class="o">=</span><span class="mi">1</span>,<span class="nv">size</span><span class="ss">(</span><span class="nv">array</span><span class="ss">))</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">SIZE:</span><span class="s1">&#39;</span>,<span class="nv">size</span><span class="ss">(</span><span class="nv">array</span><span class="ss">)</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(70(&quot;-&quot;))</span><span class="s1">&#39;</span><span class="ss">)</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span> <span class="s1">&#39;</span><span class="s">custom list of delimiters, &amp;</span>
   <span class="o">&amp;</span><span class="nv">reverse</span> <span class="nv">array</span> <span class="nv">order</span> <span class="nv">and</span> <span class="nv">count</span> <span class="nv">null</span> <span class="nv">fields</span>:<span class="s1">&#39;</span>
   <span class="k">call</span> <span class="nl">split</span><span class="ss">(</span><span class="nv">line</span>,<span class="nv">array</span>,<span class="nv">delimiters</span><span class="o">=</span><span class="s1">&#39;</span><span class="s">:|</span><span class="s1">&#39;</span>,<span class="o">&amp;</span>
   <span class="o">&amp;</span><span class="nv">order</span><span class="o">=</span><span class="s1">&#39;</span><span class="s">reverse</span><span class="s1">&#39;</span>,<span class="nv">nulls</span><span class="o">=</span><span class="s1">&#39;</span><span class="s">return</span><span class="s1">&#39;</span><span class="ss">)</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(i0,&quot; ==&gt; &quot;,a)</span><span class="s1">&#39;</span><span class="ss">)(</span><span class="nv">i</span>,<span class="nv">trim</span><span class="ss">(</span><span class="nv">array</span><span class="ss">(</span><span class="nv">i</span><span class="ss">))</span>,<span class="nv">i</span><span class="o">=</span><span class="mi">1</span>,<span class="nv">size</span><span class="ss">(</span><span class="nv">array</span><span class="ss">))</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">SIZE:</span><span class="s1">&#39;</span>,<span class="nv">size</span><span class="ss">(</span><span class="nv">array</span><span class="ss">)</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(70(&quot;-&quot;))</span><span class="s1">&#39;</span><span class="ss">)</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">INPUT LINE:[</span><span class="s1">&#39;</span><span class="o">//</span><span class="nv">line</span><span class="o">//</span><span class="s1">&#39;</span><span class="s">]</span><span class="s1">&#39;</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span> <span class="s1">&#39;</span><span class="s">default delimiters and reverse array order &amp;</span>
   <span class="o">&amp;</span><span class="nv">and</span> <span class="k">return</span> <span class="nv">null</span> <span class="nv">fields</span>:<span class="s1">&#39;</span>
   <span class="k">call</span> <span class="nl">split</span><span class="ss">(</span><span class="nv">line</span>,<span class="nv">array</span>,<span class="nv">delimiters</span><span class="o">=</span><span class="s1">&#39;&#39;</span>,<span class="nv">order</span><span class="o">=</span><span class="s1">&#39;</span><span class="s">reverse</span><span class="s1">&#39;</span>,<span class="nv">nulls</span><span class="o">=</span><span class="s1">&#39;</span><span class="s">return</span><span class="s1">&#39;</span><span class="ss">)</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="s1">&#39;</span><span class="s">(i0,&quot; ==&gt; &quot;,a)</span><span class="s1">&#39;</span><span class="ss">)(</span><span class="nv">i</span>,<span class="nv">trim</span><span class="ss">(</span><span class="nv">array</span><span class="ss">(</span><span class="nv">i</span><span class="ss">))</span>,<span class="nv">i</span><span class="o">=</span><span class="mi">1</span>,<span class="nv">size</span><span class="ss">(</span><span class="nv">array</span><span class="ss">))</span>
   <span class="nv">write</span><span class="ss">(</span><span class="o">*</span>,<span class="o">*</span><span class="ss">)</span><span class="s1">&#39;</span><span class="s">SIZE:</span><span class="s1">&#39;</span>,<span class="nv">size</span><span class="ss">(</span><span class="nv">array</span><span class="ss">)</span>
<span class="k">end</span> <span class="nv">program</span> <span class="nv">demo_split</span>
</code></pre></div>

<p>Output</p>
<blockquote>
<p>INPUT LINE:[  aBcdef   ghijklmnop qrstuvwxyz  1:|:2     333|
   333 a B cc    ]
=================================================================
typical call:
1 ==&gt; aBcdef
2 ==&gt; ghijklmnop
3 ==&gt; qrstuvwxyz
4 ==&gt; 1:|:2
5 ==&gt; 333|333
6 ==&gt; a
7 ==&gt; B
8 ==&gt; cc
SIZE:           8</p>
<hr>
<p>custom list of delimiters (colon and vertical line):
1 ==&gt;   aBcdef   ghijklmnop qrstuvwxyz  1
2 ==&gt; 2     333
3 ==&gt; 333 a B cc
SIZE:           3</p>
<hr>
<p>custom list of delimiters, reverse array order and
   return null fields:
1 ==&gt; 333 a B cc
2 ==&gt; 2     333
3 ==&gt;
4 ==&gt;
5 ==&gt;   aBcdef   ghijklmnop qrstuvwxyz  1
SIZE:           5</p>
<hr>
<p>INPUT LINE:[  aBcdef   ghijklmnop qrstuvwxyz  1:|:2     333|
   333 a B cc    ]
default delimiters and reverse array order and count null fields:
1 ==&gt;
2 ==&gt;
3 ==&gt;
4 ==&gt; cc
5 ==&gt; B
6 ==&gt; a
7 ==&gt; 333|333
8 ==&gt;
9 ==&gt;
10 ==&gt;
11 ==&gt;
12 ==&gt; 1:|:2
13 ==&gt;
14 ==&gt; qrstuvwxyz
15 ==&gt; ghijklmnop
16 ==&gt;
17 ==&gt;
18 ==&gt; aBcdef
19 ==&gt;
20 ==&gt;
SIZE:          20</p>
</blockquote>
<h2 id="author">AUTHOR</h2>
<div class="codehilite"><pre><span></span><code>John S. Urban
</code></pre></div>

<h2 id="license">LICENSE</h2>
<div class="codehilite"><pre><span></span><code>Public Domain
</code></pre></div>
    

    <h3>Arguments</h3>
    
      
<table class="table table-striped varlist">
<thead><tr><th>Type</th>
<th>Intent</th><th>Optional</th>
<th>Attributes</th><th></th><th>Name</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-input_line~2"></span>character(len=*),</td>
  <td>intent(in)</td>
  <td></td>
  
  <td></td><td>::</td>
  <td><strong>input_line</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-array~3"></span>character(len=:),</td>
  <td>intent(out),</td>
  <td></td>
  
  <td>allocatable</td><td>::</td>
  <td><strong>array</strong>(:)</td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-delimiters~6"></span>character(len=*),</td>
  <td>intent(in),</td>
  <td>optional</td>
  
  <td></td><td>::</td>
  <td><strong>delimiters</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-order"></span>character(len=*),</td>
  <td>intent(in),</td>
  <td>optional</td>
  
  <td></td><td>::</td>
  <td><strong>order</strong></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-nulls~2"></span>character(len=*),</td>
  <td>intent(in),</td>
  <td>optional</td>
  
  <td></td><td>::</td>
  <td><strong>nulls</strong></td><td></td>
  
</tr>

</tbody>
</table>

    
    
    
    
     
    <br>

    <section class="visible-xs visible-sm hidden-md">
      
<h3>Contents</h3>
 



<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title"><a data-toggle="collapse" href="#vars-1">Variables</a></h3></div>
  <div id="vars-1" class="panel-collapse collapse">
    <div class="list-group">
      
      <a class="list-group-item" href="../proc/split.html#variable-dlim~2">dlim</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-i10~5">i10</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-i20">i20</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-i30">i30</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-ibegin~4">ibegin</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-icol~2">icol</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-icount~6">icount</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-idlim~2">idlim</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-ifound~2">ifound</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-ii~2">ii</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-iiii">iiii</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-imax~2">imax</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-inotnull">inotnull</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-ireturn">ireturn</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-iterm~2">iterm</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-lgth~9">lgth</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-n~3">n</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-nlls">nlls</a>
      
      <a class="list-group-item" href="../proc/split.html#variable-ordr">ordr</a>
      
    </div>
  </div>
</div>




















<div class="panel panel-primary">
  <div class="panel-heading text-left"><h3 class="panel-title">Source Code</h3></div>
  <div class="list-group">
    <a class="list-group-item" href="../proc/split.html#src">split</a>
  </div>
</div>



    </section>
    <br class="visible-xs visible-sm hidden-md">

    

    
    <section>    
      <h2>Variables</h2>
    
<table class="table table-striped varlist">
<thead><tr><th>Type</th><th>Visibility</th>

<th>Attributes</th><th></th><th>Name</th><th></th><th>Initial</th><th></th></thead>



<tbody>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-dlim~2"></span>character(len=:),</td>
  
  <td>public,</td>
  <td>allocatable</td><td>::</td>
  <td><strong>dlim</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-i10~5"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>i10</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-i20"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>i20</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-i30"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>i30</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ibegin~4"></span>integer,</td>
  
  <td>public,</td>
  <td>allocatable</td><td>::</td>
  <td><strong>ibegin</strong>(:)</td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-icol~2"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>icol</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-icount~6"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>icount</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-idlim~2"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>idlim</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ifound~2"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>ifound</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ii~2"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>ii</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-iiii"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>iiii</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-imax~2"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>imax</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-inotnull"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>inotnull</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ireturn"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>ireturn</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-iterm~2"></span>integer,</td>
  
  <td>public,</td>
  <td>allocatable</td><td>::</td>
  <td><strong>iterm</strong>(:)</td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-lgth~9"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>lgth</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-n~3"></span>integer,</td>
  
  <td>public</td>
  <td></td><td>::</td>
  <td><strong>n</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-nlls"></span>character(len=:),</td>
  
  <td>public,</td>
  <td>allocatable</td><td>::</td>
  <td><strong>nlls</strong></td><td></td><td></td><td></td>
  
</tr>

  
  
  
  
<tr>
  
  <td><span class="anchor" id="variable-ordr"></span>character(len=:),</td>
  
  <td>public,</td>
  <td>allocatable</td><td>::</td>
  <td><strong>ordr</strong></td><td></td><td></td><td></td>
  
</tr>

</tbody>
</table>

    </section>
    <br>
    
    
    
    
    

    
    
    
    
    


    
    
    
    <section>
    <h2><span class="anchor" id="src"></span>Source Code</h2>
    <div class="highlight"><pre><span></span><span class="k">subroutine </span><span class="n">split</span><span class="p">(</span><span class="n">input_line</span><span class="p">,</span><span class="k">array</span><span class="p">,</span><span class="n">delimiters</span><span class="p">,</span><span class="n">order</span><span class="p">,</span><span class="n">nulls</span><span class="p">)</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>

<span class="c">! ident_8=&quot;@(#)M_strings::split(3f): parse string on delimiter characters and store tokens into an allocatable array&quot;</span>

<span class="c">!  John S. Urban</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
<span class="k">intrinsic </span><span class="nb">index</span><span class="p">,</span> <span class="nb">min</span><span class="p">,</span> <span class="nb">present</span><span class="p">,</span> <span class="nb">len</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
<span class="c">!  given a line of structure &quot; par1 par2 par3 ... parn &quot; store each par(n) into a separate variable in array.</span>
<span class="c">!    o by default adjacent delimiters in the input string do not create an empty string in the output array</span>
<span class="c">!    o no quoting of delimiters is supported</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>              <span class="kd">::</span> <span class="n">input_line</span>  <span class="c">! input string to tokenize</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">optional</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>     <span class="kd">::</span> <span class="n">delimiters</span>  <span class="c">! list of delimiter characters</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">optional</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>     <span class="kd">::</span> <span class="n">order</span>       <span class="c">! order of output array sequential|[reverse|right]</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=*</span><span class="p">),</span><span class="k">optional</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">in</span><span class="p">)</span>     <span class="kd">::</span> <span class="n">nulls</span>       <span class="c">! return strings composed of delimiters or not ignore|return|ignoreend</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="p">:),</span><span class="k">allocatable</span><span class="p">,</span><span class="k">intent</span><span class="p">(</span><span class="n">out</span><span class="p">)</span> <span class="kd">::</span> <span class="k">array</span><span class="p">(:)</span>    <span class="c">! output array of tokens</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
<span class="kt">integer</span>                       <span class="kd">::</span> <span class="n">n</span>                      <span class="c">! max number of strings INPUT_LINE could split into if all delimiter</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">allocatable</span>           <span class="kd">::</span> <span class="n">ibegin</span><span class="p">(:)</span>              <span class="c">! positions in input string where tokens start</span>
<span class="kt">integer</span><span class="p">,</span><span class="k">allocatable</span>           <span class="kd">::</span> <span class="n">iterm</span><span class="p">(:)</span>               <span class="c">! positions in input string where tokens end</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="p">:),</span><span class="k">allocatable</span>  <span class="kd">::</span> <span class="n">dlim</span>                   <span class="c">! string containing delimiter characters</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="p">:),</span><span class="k">allocatable</span>  <span class="kd">::</span> <span class="n">ordr</span>                   <span class="c">! string containing order keyword</span>
<span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="p">:),</span><span class="k">allocatable</span>  <span class="kd">::</span> <span class="n">nlls</span>                   <span class="c">! string containing nulls keyword</span>
<span class="kt">integer</span>                       <span class="kd">::</span> <span class="n">ii</span><span class="p">,</span><span class="n">iiii</span>                <span class="c">! loop parameters used to control print order</span>
<span class="kt">integer</span>                       <span class="kd">::</span> <span class="n">icount</span>                 <span class="c">! number of tokens found</span>
<span class="kt">integer</span>                       <span class="kd">::</span> <span class="n">lgth</span>                   <span class="c">! length of input string with trailing spaces trimmed</span>
<span class="kt">integer</span>                       <span class="kd">::</span> <span class="n">i10</span><span class="p">,</span><span class="n">i20</span><span class="p">,</span><span class="n">i30</span>            <span class="c">! loop counters</span>
<span class="kt">integer</span>                       <span class="kd">::</span> <span class="n">icol</span>                   <span class="c">! pointer into input string as it is being parsed</span>
<span class="kt">integer</span>                       <span class="kd">::</span> <span class="n">idlim</span>                  <span class="c">! number of delimiter characters</span>
<span class="kt">integer</span>                       <span class="kd">::</span> <span class="n">ifound</span>                 <span class="c">! where next delimiter character is found in remaining input string data</span>
<span class="kt">integer</span>                       <span class="kd">::</span> <span class="n">inotnull</span>               <span class="c">! count strings not composed of delimiters</span>
<span class="kt">integer</span>                       <span class="kd">::</span> <span class="n">ireturn</span>                <span class="c">! number of tokens returned</span>
<span class="kt">integer</span>                       <span class="kd">::</span> <span class="n">imax</span>                   <span class="c">! length of longest token</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="c">! decide on value for optional DELIMITERS parameter</span>
   <span class="k">if</span> <span class="p">(</span><span class="nb">present</span><span class="p">(</span><span class="n">delimiters</span><span class="p">))</span> <span class="k">then</span>                                     <span class="c">! optional delimiter list was present</span>
      <span class="k">if</span><span class="p">(</span><span class="n">delimiters</span><span class="p">.</span><span class="n">ne</span><span class="p">.</span><span class="s1">&#39;&#39;</span><span class="p">)</span><span class="k">then</span>                                       <span class="c">! if DELIMITERS was specified and not null use it</span>
         <span class="n">dlim</span><span class="o">=</span><span class="n">delimiters</span>
      <span class="k">else</span>                                                           <span class="c">! DELIMITERS was specified on call as empty string</span>
         <span class="n">dlim</span><span class="o">=</span><span class="s1">&#39; &#39;</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">9</span><span class="p">)</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">11</span><span class="p">)</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">12</span><span class="p">)</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">13</span><span class="p">)</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="c">! use default delimiter when not specified</span>
      <span class="k">endif</span>
<span class="k">   else</span>                                                              <span class="c">! no delimiter value was specified</span>
      <span class="n">dlim</span><span class="o">=</span><span class="s1">&#39; &#39;</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">9</span><span class="p">)</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">11</span><span class="p">)</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">12</span><span class="p">)</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">13</span><span class="p">)</span><span class="o">//</span><span class="nb">char</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>    <span class="c">! use default delimiter when not specified</span>
   <span class="k">endif</span>
<span class="k">   </span><span class="n">idlim</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">dlim</span><span class="p">)</span>                                                   <span class="c">! dlim a lot of blanks on some machines if dlim is a big string</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="k">if</span><span class="p">(</span><span class="nb">present</span><span class="p">(</span><span class="n">order</span><span class="p">))</span><span class="k">then</span><span class="p">;</span> <span class="n">ordr</span><span class="o">=</span><span class="n">lower</span><span class="p">(</span><span class="nb">adjustl</span><span class="p">(</span><span class="n">order</span><span class="p">));</span> <span class="k">else</span><span class="p">;</span> <span class="n">ordr</span><span class="o">=</span><span class="s1">&#39;sequential&#39;</span><span class="p">;</span> <span class="k">endif</span> <span class="c">! decide on value for optional ORDER parameter</span>
   <span class="k">if</span><span class="p">(</span><span class="nb">present</span><span class="p">(</span><span class="n">nulls</span><span class="p">))</span><span class="k">then</span><span class="p">;</span> <span class="n">nlls</span><span class="o">=</span><span class="n">lower</span><span class="p">(</span><span class="nb">adjustl</span><span class="p">(</span><span class="n">nulls</span><span class="p">));</span> <span class="k">else</span><span class="p">;</span> <span class="n">nlls</span><span class="o">=</span><span class="s1">&#39;ignore&#39;</span>    <span class="p">;</span> <span class="k">endif</span> <span class="c">! optional parameter</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="n">n</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">input_line</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span>                        <span class="c">! max number of strings INPUT_LINE could split into if all delimiter</span>
   <span class="k">if</span><span class="p">(</span><span class="nb">allocated</span><span class="p">(</span><span class="n">ibegin</span><span class="p">))</span><span class="k">deallocate</span><span class="p">(</span><span class="n">ibegin</span><span class="p">)</span>    <span class="c">!x! intel compiler says allocated already ?</span>
   <span class="k">if</span><span class="p">(</span><span class="nb">allocated</span><span class="p">(</span><span class="n">iterm</span><span class="p">))</span><span class="k">deallocate</span><span class="p">(</span><span class="n">iterm</span><span class="p">)</span>      <span class="c">!x! intel compiler says allocated already ?</span>
   <span class="k">allocate</span><span class="p">(</span><span class="n">ibegin</span><span class="p">(</span><span class="n">n</span><span class="p">))</span>                        <span class="c">! allocate enough space to hold starting location of tokens if string all tokens</span>
   <span class="k">allocate</span><span class="p">(</span><span class="n">iterm</span><span class="p">(</span><span class="n">n</span><span class="p">))</span>                         <span class="c">! allocate enough space to hold ending location of tokens if string all tokens</span>
   <span class="n">ibegin</span><span class="p">(:)</span><span class="o">=</span><span class="mi">1</span>
   <span class="n">iterm</span><span class="p">(:)</span><span class="o">=</span><span class="mi">1</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="n">lgth</span><span class="o">=</span><span class="nb">len</span><span class="p">(</span><span class="n">input_line</span><span class="p">)</span>                                           <span class="c">! lgth is the column position of the last non-blank character</span>
   <span class="n">icount</span><span class="o">=</span><span class="mi">0</span>                                                       <span class="c">! how many tokens found</span>
   <span class="n">inotnull</span><span class="o">=</span><span class="mi">0</span>                                                     <span class="c">! how many tokens found not composed of delimiters</span>
   <span class="n">imax</span><span class="o">=</span><span class="mi">0</span>                                                         <span class="c">! length of longest token found</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="k">if</span><span class="p">(</span><span class="n">lgth</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>                                              <span class="c">! there is at least one non-delimiter in INPUT_LINE if get here</span>
      <span class="n">icol</span><span class="o">=</span><span class="mi">1</span>                                                      <span class="c">! initialize pointer into input line</span>
      <span class="n">INFINITE</span><span class="p">:</span> <span class="k">do </span><span class="n">i30</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="n">lgth</span><span class="p">,</span><span class="mi">1</span>                                   <span class="c">! store into each array element</span>
         <span class="n">ibegin</span><span class="p">(</span><span class="n">i30</span><span class="p">)</span><span class="o">=</span><span class="n">icol</span>                                         <span class="c">! assume start new token on the character</span>
         <span class="k">if</span><span class="p">(</span><span class="nb">index</span><span class="p">(</span><span class="n">dlim</span><span class="p">(</span><span class="mi">1</span><span class="p">:</span><span class="n">idlim</span><span class="p">),</span><span class="n">input_line</span><span class="p">(</span><span class="n">icol</span><span class="p">:</span><span class="n">icol</span><span class="p">)).</span><span class="n">eq</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>  <span class="c">! if current character is not a delimiter</span>
            <span class="n">iterm</span><span class="p">(</span><span class="n">i30</span><span class="p">)</span><span class="o">=</span><span class="n">lgth</span>                                       <span class="c">! initially assume no more tokens</span>
            <span class="k">do </span><span class="n">i10</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="n">idlim</span>                                        <span class="c">! search for next delimiter</span>
               <span class="n">ifound</span><span class="o">=</span><span class="nb">index</span><span class="p">(</span><span class="n">input_line</span><span class="p">(</span><span class="n">ibegin</span><span class="p">(</span><span class="n">i30</span><span class="p">):</span><span class="n">lgth</span><span class="p">),</span><span class="n">dlim</span><span class="p">(</span><span class="n">i10</span><span class="p">:</span><span class="n">i10</span><span class="p">))</span>
               <span class="k">IF</span><span class="p">(</span><span class="n">ifound</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span><span class="k">then</span>
<span class="k">                  </span><span class="n">iterm</span><span class="p">(</span><span class="n">i30</span><span class="p">)</span><span class="o">=</span><span class="nb">min</span><span class="p">(</span><span class="n">iterm</span><span class="p">(</span><span class="n">i30</span><span class="p">),</span><span class="n">ifound</span><span class="o">+</span><span class="n">ibegin</span><span class="p">(</span><span class="n">i30</span><span class="p">)</span><span class="o">-</span><span class="mi">2</span><span class="p">)</span>
               <span class="k">endif</span>
<span class="k">            enddo</span>
<span class="k">            </span><span class="n">icol</span><span class="o">=</span><span class="n">iterm</span><span class="p">(</span><span class="n">i30</span><span class="p">)</span><span class="o">+</span><span class="mi">2</span>                                     <span class="c">! next place to look as found end of this token</span>
            <span class="n">inotnull</span><span class="o">=</span><span class="n">inotnull</span><span class="o">+</span><span class="mi">1</span>                                   <span class="c">! increment count of number of tokens not composed of delimiters</span>
         <span class="k">else</span>                                                     <span class="c">! character is a delimiter for a null string</span>
            <span class="n">iterm</span><span class="p">(</span><span class="n">i30</span><span class="p">)</span><span class="o">=</span><span class="n">icol</span><span class="o">-</span><span class="mi">1</span>                                     <span class="c">! record assumed end of string. Will be less than beginning</span>
            <span class="n">icol</span><span class="o">=</span><span class="n">icol</span><span class="o">+</span><span class="mi">1</span>                                           <span class="c">! advance pointer into input string</span>
         <span class="k">endif</span>
<span class="k">         </span><span class="n">imax</span><span class="o">=</span><span class="nb">max</span><span class="p">(</span><span class="n">imax</span><span class="p">,</span><span class="n">iterm</span><span class="p">(</span><span class="n">i30</span><span class="p">)</span><span class="o">-</span><span class="n">ibegin</span><span class="p">(</span><span class="n">i30</span><span class="p">)</span><span class="o">+</span><span class="mi">1</span><span class="p">)</span>
         <span class="n">icount</span><span class="o">=</span><span class="n">i30</span>                                               <span class="c">! increment count of number of tokens found</span>
         <span class="k">if</span><span class="p">(</span><span class="n">icol</span><span class="p">.</span><span class="n">gt</span><span class="p">.</span><span class="n">lgth</span><span class="p">)</span><span class="k">then</span>                                     <span class="c">! no text left</span>
            <span class="k">exit </span><span class="n">INFINITE</span>
         <span class="k">endif</span>
<span class="k">      enddo </span><span class="n">INFINITE</span>
   <span class="k">endif</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="k">select case</span> <span class="p">(</span><span class="nb">trim</span><span class="p">(</span><span class="nb">adjustl</span><span class="p">(</span><span class="n">nlls</span><span class="p">)))</span>
   <span class="k">case</span> <span class="p">(</span><span class="s1">&#39;ignore&#39;</span><span class="p">,</span><span class="s1">&#39;&#39;</span><span class="p">,</span><span class="s1">&#39;ignoreend&#39;</span><span class="p">)</span>
      <span class="n">ireturn</span><span class="o">=</span><span class="n">inotnull</span>
   <span class="k">case </span><span class="n">default</span>
      <span class="n">ireturn</span><span class="o">=</span><span class="n">icount</span>
   <span class="k">end select</span>
<span class="k">   allocate</span><span class="p">(</span><span class="kt">character</span><span class="p">(</span><span class="nb">len</span><span class="o">=</span><span class="n">imax</span><span class="p">)</span> <span class="kd">::</span> <span class="k">array</span><span class="p">(</span><span class="n">ireturn</span><span class="p">))</span>                <span class="c">! allocate the array to return</span>
   <span class="c">!allocate(array(ireturn))                                       ! allocate the array to return</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="k">select case</span> <span class="p">(</span><span class="nb">trim</span><span class="p">(</span><span class="nb">adjustl</span><span class="p">(</span><span class="n">ordr</span><span class="p">)))</span>                              <span class="c">! decide which order to store tokens</span>
   <span class="k">case</span> <span class="p">(</span><span class="s1">&#39;reverse&#39;</span><span class="p">,</span><span class="s1">&#39;right&#39;</span><span class="p">)</span> <span class="p">;</span> <span class="n">ii</span><span class="o">=</span><span class="n">ireturn</span> <span class="p">;</span> <span class="n">iiii</span><span class="o">=-</span><span class="mi">1</span>                <span class="c">! last to first</span>
   <span class="k">case </span><span class="n">default</span>             <span class="p">;</span> <span class="n">ii</span><span class="o">=</span><span class="mi">1</span>       <span class="p">;</span> <span class="n">iiii</span><span class="o">=</span><span class="mi">1</span>                 <span class="c">! first to last</span>
   <span class="k">end select</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="k">do </span><span class="n">i20</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="n">icount</span>                                                <span class="c">! fill the array with the tokens that were found</span>
      <span class="k">if</span><span class="p">(</span><span class="n">iterm</span><span class="p">(</span><span class="n">i20</span><span class="p">).</span><span class="n">lt</span><span class="p">.</span><span class="n">ibegin</span><span class="p">(</span><span class="n">i20</span><span class="p">))</span><span class="k">then</span>
<span class="k">         select case</span> <span class="p">(</span><span class="nb">trim</span><span class="p">(</span><span class="nb">adjustl</span><span class="p">(</span><span class="n">nlls</span><span class="p">)))</span>
         <span class="k">case</span> <span class="p">(</span><span class="s1">&#39;ignore&#39;</span><span class="p">,</span><span class="s1">&#39;&#39;</span><span class="p">,</span><span class="s1">&#39;ignoreend&#39;</span><span class="p">)</span>
         <span class="k">case </span><span class="n">default</span>
            <span class="k">array</span><span class="p">(</span><span class="n">ii</span><span class="p">)</span><span class="o">=</span><span class="s1">&#39; &#39;</span>
            <span class="n">ii</span><span class="o">=</span><span class="n">ii</span><span class="o">+</span><span class="n">iiii</span>
         <span class="k">end select</span>
<span class="k">      else</span>
<span class="k">         array</span><span class="p">(</span><span class="n">ii</span><span class="p">)</span><span class="o">=</span><span class="n">input_line</span><span class="p">(</span><span class="n">ibegin</span><span class="p">(</span><span class="n">i20</span><span class="p">):</span><span class="n">iterm</span><span class="p">(</span><span class="n">i20</span><span class="p">))</span>
         <span class="n">ii</span><span class="o">=</span><span class="n">ii</span><span class="o">+</span><span class="n">iiii</span>
      <span class="k">endif</span>
<span class="k">   enddo</span>
<span class="c">!-----------------------------------------------------------------------------------------------------------------------------------</span>
   <span class="k">end subroutine </span><span class="n">split</span>
</pre></div>

    </section>
    <br>
    
    
    </div>
  </div>


    <hr>    
    </div> <!-- /container -->
    <footer>
      <div class="container">
      <div class="row">
        <div class="col-xs-6 col-md-4"><p>&copy; 2022 
                                          </p></div>
        <div class="col-xs-6 col-md-4 col-md-push-4">
          <p class="text-right">
            Documentation generated by 
            <a href="https://github.com/cmacmackin/ford">FORD</a>
             on 2022-01-16 22:32  
          </p>
        </div>
        <div class="col-xs-12 col-md-4 col-md-pull-4"><p class="text-center"> M_strings was developed by John S. Urban</p></div>
      </div>
      <br>
      </div> <!-- /container -->    
    </footer>

    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
<!--
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
-->
    <script src="../js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="../js/ie10-viewport-bug-workaround.js"></script>

    <!-- MathJax JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        TeX: { extensions: ['AMSmath.js','AMSsymbols.js','noErrors.js','noUndefined.js'], equationNumbers: { autoNumber: 'AMS' } },
        jax: ['input/TeX','input/MathML','output/HTML-CSS'],
        extensions: ['tex2jax.js','mml2jax.js','MathMenu.js','MathZoom.js']
      });
    </script>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    
    <script src="../tipuesearch/tipuesearch_content.js"></script>
    <script src="../tipuesearch/tipuesearch_set.js"></script>
    <script src="../tipuesearch/tipuesearch.js"></script>
    
    
  </body>
</html>